<?php


namespace app\index\model;
use think\Db;
use think\Model;


class zhxmdh extends Model
{


    protected $table = 'xt_xmzhsf';

    //根据项目检验目的代号返回结果  --单项
    public function GetZhmsfByzhXmdh($zhxmdh)
    {
        return $res = Db::table('xt_zhxmsf')->where('zhxmdh', $zhxmdh)->select();
    }

    //根据项目  检验目的代号  查询
    public  function GetZhmsfByData($data){
        $zhdh = trim($data['zhdh']);
        $yqdh = trim($data['yqdh']);
        //$zhsf = trim($data['zhsf']);
        if (isset($data['khmc'])) {
            $khmc = $data['khmc'];
        } else {
            $khmc = '';
        }
        $res = Db::name('xt_xmzhsf')->where(['zhdh'=>$zhdh,'yqdh'=>$yqdh,'khmc'=>$khmc])->select();
        if(Empty($res)){
            return false;
        }
        return $res;
    }


    //根据项目 检验目的代号  插入  结果
    public function InsertZhmsfByzhXmdh($data)
    {
        $zhdh = trim($data['zhdh']);
        $yqdh = trim($data['yqdh']);
        $zhsf = trim($data['zhsf']);
        $starttime = $data['starttime'];
        $endtime = $data['endtime'];
        //$pv  = 6 ;
        //$jb  = 3 ;
        if (isset($data['khmc'])) {
            $khmc = $data['khmc'];
        } else {
            $khmc = '';
        }
        //开始添加
        $res = Db::execute("INSERT INTO xt_xmzhsf ( yqdh, zhdh, brlb, zhsf,  khmc,starttime, endtime, pv, jb )
                 VALUES ( :yqdh, :zhdh, '[none]', :zhsf, :khmc, :starttime, :endtime, '6', '3' )",
            ['yqdh' => $yqdh, 'zhdh' => $zhdh, 'zhsf'=>$zhsf,'khmc'=>$khmc,'starttime' => $starttime, 'endtime' => $endtime]);


        if ($res) {
            return true;
        }

        return false;

    }
}